//
//  MBRefreshFooterView.m
//  MobellCloud_ios
//
//  Created by cherry pu on 2017/12/21.
//  Copyright © 2017年 zhangXin. All rights reserved.
//

#import "MBRefreshFooterView.h"

@interface MBRefreshFooterView ()
@property (nonatomic,weak) UILabel* titleLabel;
@property (nonatomic,weak) UIImageView* smileImageView;

@end

@implementation MBRefreshFooterView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        
        self.backgroundColor = COLOR_BG;
                
        UILabel* titleLabel = [[UILabel alloc]init];
        self.titleLabel = titleLabel;
        titleLabel.text = @"正在努力加载";
        titleLabel.font = [UIFont lf_systemFontOfSize:11];
        titleLabel.textColor = [UIColor colorWithR:187 G:187 B:187];
        [self addSubview:titleLabel];
        
        [titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self).with.offset([UIView lf_sizeFromIphone6:18]);
            make.centerX.equalTo(self);
        }];
        
        UIImageView* smileImageView = [[UIImageView alloc]init];
        self.smileImageView = smileImageView;
        smileImageView.image = [UIImage imageNamed:@"loading"];
        [self addSubview:smileImageView];
        
        [smileImageView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerX.equalTo(self);
            make.top.equalTo(titleLabel.mas_bottom).with.offset([UIView lf_sizeFromIphone6:10]);
        }];

    }
    return self;
}

-(void)setType:(MBFooterType)type
{
    _type = type;
    
    if (type == kLoadingType) {
        self.titleLabel.text = @"正在努力加载";
        self.smileImageView.image = [UIImage imageNamed:@"loading"];
    }else {
        self.titleLabel.text = @"加载完毕";
        self.smileImageView.image = [UIImage imageNamed:@"end_load"];
    }
}

@end
